package basic;

/**
 *  interface 中的字段
 */

public class InterfaceClass {
    public static void main(String[] args) {
        Animal [] animals = {
                new Dog(),
                new Bird(),
                new Dog(),
        };

        for (Animal animal:animals) {
            animal.run();
        }


        Dog c = new Dog();
        Dog.sex_female=0;
        Dog.sex_male=1;
        System.out.println(c.sex_female);

        System.out.println(Animal.male);
        System.out.println(Dog.male);
        System.out.println(Dog.getCounter());

    }

}

interface Animal{
    int male=1;
    int female=0;
    void run();
    String shout();
    void hunt();
}

class Dog implements Animal{

    public static int sex_male;
    public static int sex_female;

    public static int counter;

    public Dog() {
        counter++;
    }

    public static int getCounter(){
        return counter;
    }

    @Override
    public void run() {
        System.out.println("dog is running...");
    }

    @Override
    public String shout() {
        return "wangwangwang";
    }

    @Override
    public void hunt() {
        System.out.println("Dog is hunting");
    }
}


class Bird implements Animal{
    @Override
    public void run() {
        System.out.println("Birds Are flying...");
    }

    @Override
    public String shout() {
        return "yingyingying";
    }

    @Override
    public void hunt() {
        System.out.println("Birds Are huntings");
    }
}